
/**
 * 发送给用户管理员信息
 */
exports.getAllAdminInfo = function (UserList, AdminList) {
    UserList.forEach(item => {
        let data = AdminList.map(item => {
            return {
                name: item.name,
                uid: item.uid,
                radio: item.radio,
                state: item.state
            }
        })
        item.socket.emit('AdminListInfo', data)
    })
}

/**
 * 寻找用户所对应的Socket
 */
exports.findUserStocket = function (UserList, socket) {
    let UserSocket = UserList.find(item => {
        if (item.socket.id == socket.id) {
            return true;
        }
    })
    return UserSocket;
}

/**
 * 寻找客服所对应的Socket
 */
exports.findAdminStocket = function (AdminList, socket) {
    let AdminSocket = AdminList.find(item => {
        if (item.socket.id == socket.id) {
            return true;
        }
    });
    return AdminSocket;
}


/**
 * 根据用户Socket寻找要发送的客服Aocket
 */

exports.findAdminByUser = function (AdminList, UserSocket) {
    if (!UserSocket.to) {
        return false;
    }
    let AdminSocket = AdminList.find(item => {
        if (item.uid == UserSocket.to) {
            return true;
        }
    });
    return AdminSocket;
}

/**
 * 根据客服Socket寻找要发送的用户Aocket
 */
exports.findUserByAdmin = function (UserList, AdminSocket) {
    if (!AdminSocket.to) {
        return false;
    }
    let UserSocket = UserList.find(item => {
        if (item.uid == AdminSocket.to) {
            return true;
        }
    });
    return UserSocket;
}